<?php
Yii::import('ext.qtip.QTip');
QTip::qtip('span[title]');
?>
<div style="width:100%; float:left; margin-bottom:10px; text-align:right;">
<form action="" method="post" name="batch" id="batch">
	<table width="100%" border="0" cellpadding="0" cellspacing="0">		
		<tr>
			<td width="15%" class="td_right"><?php echo $labels['Inspector']; ?>: </td>
			<td width="35%">
				<?php echo CHtml::textField('Inspector','',array('class'=>'input_size4')); ?>
			</td>
			<td width="15%" class="td_right"><?php echo $labels['InspectDate']; ?>: </td>		
			<td>
				<?php $this->widget('zii.widgets.jui.CJuiDatePicker',array(  
						'attribute'=>'InspectDate',  
						'language'=>'zh_cn',  
						'name'=>'InspectDate',  
						'options'=>array(  
							'showAnim'=>'fold',  
							'dateFormat'=>'yymmdd',  
						),  
						'htmlOptions'=>array(  
							'class'=>'input_size4',
						),  
					));  
				?>
			</td>
		</tr>
		<tr>
			<td class="td_right"><?php echo $labels['Event']; ?>: </td>
			<td colspan="3">
				<?php echo CHtml::dropDownList('Event','Event',Yii::app()->params['event'],array('class'=>'input_size6')); ?>
			</td>			
		</tr>
	</table>
	<table cellspacing="0" cellpadding="0" width="100%" class="tbl" style="float:left;">
		<tr class="head">
			<td width="2%"><input type="checkbox" name="checkAll" id="checkAll"></td>
			<td width="8%"><?php echo $labels['ProductModel']; ?></td>
			<td width="12%"><?php echo $labels['ProductDetail']; ?></td>
			<td width="6%"><?php echo $labels['PQuantity']; ?></td>
			<td width="8%"><?php echo $labels['Balance']; ?></td>
			<td width="10%">单品尺寸_长(cm)</td>
			<td width="10%">单品尺寸_宽(cm)</td>
			<td width="10%">单品尺寸_高(cm)</td>
			<td width="6%">重量</td>
			<td><?php echo $labels['OEFeedback']; ?></td>
		</tr>
		<?php
		$i = 0;
		$cssArr = array(0 => 'even', 1 => 'odd', 2 => 'three');
		foreach ($rowTable as $item) {
			$trClass = $cssArr[$i % 3];
			$i++;
			$content = "<span style='line-height:20px; font-size:12px;'>";
			$content .= $labels['Inspector'].'：'.$item->Inspector.'<br />';
			$content .= $labels['InspectDate'].'：'.$item->InspectDate.'<br />';
			$content .= $labels['Event'].'：'.$item->Event.'<br />';
			$content .= $labels['ToLAMethod'].'：'.$item->ToLAMethod.'<br />';
			$content .= $labels['CarrierNumber'].'：'.$item->CarrierNumber.'<br />';
			$content .= '</span>';
			?>
		<tr class="<?= $trClass ?>">
			<td style="text-align:center;"><input type="checkbox" name="PricingIndex[]" id="PricingIndex_<?=$item->PricingIndex?>" value="<?=$item->PricingIndex?>"></td>
			<td>
				<span title="<?=$content?>"><?=$item->product->ProductModel?></span>
			</td>
			<td>
				<span title="<span style='line-height:20px; font-size:12px;'><?=$item->product->ProductDetail?></span>"><?=Helper::truncate_utf8_string($item->product->ProductDetail,5,'')?></span>
			</td>
			<td style="text-align:center;">
				<?=$item->PQuantity?>
			</td>
			<td style="text-align:center;">
				<?=$item->Balance?>
			</td>
			<td style="text-align:center;">
				<?php echo CHtml::textField('ProdPackL_cm_'.$item->PricingIndex,$item->product->ProdPackL_cm,array('style'=>'width:30px;')); ?>
			</td>
			<td style="text-align:center;">
				<?php echo CHtml::textField('ProdPackW_cm_'.$item->PricingIndex,$item->product->ProdPackW_cm,array('style'=>'width:30px;')); ?>
			</td>
			<td style="text-align:center;">
				<?php echo CHtml::textField('ProdPackH_cm_'.$item->PricingIndex,$item->product->ProdPackH_cm,array('style'=>'width:30px;')); ?>
			</td>
			<td style="text-align:center;">
				<?php echo CHtml::textField('WeightG_'.$item->PricingIndex,$item->product->WeightG,array('style'=>'width:30px;')); ?>
			</td>
		
			<td style="text-align:center;">
				<?php echo CHtml::textArea('OEFeedback_'.$item->PricingIndex,$item->OEFeedback,array('style'=>'width:260px;')); ?>
			</td>
		</tr>
		<?php
		}
		?>
	</table>
	<div style="text-align:center;"><input type="button" onclick="fxl()" name="batchSub" value="更新" /></div>	
	<input type="hidden" name="ReceiptNo" value="<?=$receiptNo?>" />
</form>
</div>
<script type="text/javascript">
/*<![CDATA[*/
jQuery(function($) {
$(document).on('click','#checkAll',function() {
	var checked=this.checked;
	$("input[name='PricingIndex\[\]']").each(function() {this.checked=checked;});
});
$(document).on('click', "input[name='PricingIndex\[\]']", function() {
	$('#PricingIndex').prop('checked', $("input[name='PricingIndex\[\]']").length==$("input[name='PricingIndex\[\]']:checked").length);
});
});
function check(id,product,quantity,balance,tola){
	if(parseInt(tola)>parseInt(quantity)){
		alert(product+' 运出数量不能大于购买数量');
		$('#ToLAQty_'+id).focus();
		return false;
	}
	if(parseInt(tola)>parseInt(balance)){
		alert(product+' 运出数量不能大于未出货数量');
		$('#ToLAQty_'+id).focus();
		return false;
	}
	return true;
}
function fxl(){
	var selectItem = false;
<?php
foreach ($rowTable as $item) {
?>
	if($("#PricingIndex_<?=$item->PricingIndex?>").is(":checked")){
		selectItem = true;
		if(!check('<?=$item->PricingIndex?>','<?=$item->product->ProductModel?>','<?=$item->PQuantity?>','<?=$item->Balance?>',$('#ToLAQty_<?=$item->PricingIndex?>').val())){
			return false;
		}
	}
<?php
}
?>
if(selectItem){
	document.forms.batch.submit();
}else{
	alert('请选择需要更新的记录');
}

}
/*]]>*/
</script>